package com.sysu.homework.DAO.Impl;

import javax.annotation.Resource;

import org.springframework.orm.hibernate3.HibernateTemplate;
import org.springframework.stereotype.Component;

import com.sysu.homework.DAO.TeacherDAO;
import com.sysu.homework.model.Teacher;

@Component("teacherDAO")
public class TeacherDAOImpl implements TeacherDAO {
	private HibernateTemplate hibernateTemplate;

	@Override
	public Teacher getTeacherById(int id) {
		Teacher teacher = (Teacher)hibernateTemplate.get(Teacher.class, id);
		return teacher;
	}
	
	@Override
	public boolean isValid(int id, String password) {
		Teacher teacher = (Teacher)hibernateTemplate.get(Teacher.class, id);
		if (teacher != null && teacher.getPassword().equals(password))
			return true;
		return false;
	}

	@Resource
	public void setHibernateTemplate(HibernateTemplate hibernateTemplate) {
		this.hibernateTemplate = hibernateTemplate;
	}

	public HibernateTemplate getHibernateTemplate() {
		return hibernateTemplate;
	}

	

}
